<?php
/**
 * Description: 新品速递 标签/优点表
 * Created by PhpStorm.
 * User: congyukun
 * Date: 2021/5/20
 * Time: 11:06
 */

namespace Biz\model\NewProduct;


use Hhz\Mysql\BaseDbModel;

class NewProductTagModel extends BaseDbModel
{
    public const _CONFIG_FILE_ = 'db_store';

    public const _CONFIG_SELECT_ = 'db_brand_activity';

    public const _DATABASE_ = 'brand_activity';

    public const _TABLE_NAME = 'new_product_tag';
    // 状态1:启用 0 :关闭
    public const STATUS_ON = 1;
    public const STATUS_OFF = 0;


    /**
     * 获取一行
     * @param $where
     * @param string $field
     * @return array|mixed|null
     */
    public static function first($where, $field = '*')
    {
        $rs = self::get($field, $where);
        if (!$rs) {
            return null;
        }
        return $rs;
    }

    /**
     * 批量查询
     * @param $where
     * @param  $field
     * @return array|bool
     */
    public static function all($where, $field)
    {
        return self::select($field, $where);
    }

    /**
     * 获取一列的值
     * @param $where
     * @param array $field
     * @return array|bool
     */
    public static function pluck($where, array $field = ['id'])
    {
        return self::select($field, $where);
    }

    /**
     * 从记录中获取单个值
     * @param $where
     * @param string $columns
     * @return array|bool
     */
    public static function value($where, string $columns = 'id')
    {
        return self::get($columns, $where);
    }

    public static function left_join($table, $main_col, $attach_col, $field, $where)
    {
        $join = ['[>]' . $table => [$main_col => $attach_col]];
        return self::select($join, $field, $where);
    }

}